\doxysection{my\+\_\+binary\+\_\+tree\texorpdfstring{$<$}{<} T \texorpdfstring{$>$}{>} Class Template Reference}
\hypertarget{classmy__binary__tree}{}\label{classmy__binary__tree}\index{my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}}


二叉树类（模板类，支持任意数据类型\+T）  




{\ttfamily \#include $<$my\+\_\+binary\+\_\+tree.\+h$>$}



Inheritance diagram for my\+\_\+binary\+\_\+tree\texorpdfstring{$<$}{<} T \texorpdfstring{$>$}{>}\+:
% FIG 0
\doxysubsubsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\mbox{\hyperlink{classmy__binary__tree_ae19ca02504d47a17836f0b0c533f8982}{my\+\_\+binary\+\_\+tree}} (T val)
\begin{DoxyCompactList}\small\item\em 构造函数（创建单个节点） \end{DoxyCompactList}\item 
\mbox{\hyperlink{classmy__binary__tree_a6faf690077dab82f4d1f72920c3834fd}{my\+\_\+binary\+\_\+tree}} (const \mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ \&other)
\begin{DoxyCompactList}\small\item\em 拷贝构造函数（深拷贝） \end{DoxyCompactList}\item 
\mbox{\hyperlink{classmy__binary__tree_aabd378c4f70ed8c8e76691769d111c59}{\texorpdfstring{$\sim$}{\string~}my\+\_\+binary\+\_\+tree}} ()
\begin{DoxyCompactList}\small\item\em 析构函数（递归释放内存） \end{DoxyCompactList}\item 
\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ \texorpdfstring{$\ast$}{*} \mbox{\hyperlink{classmy__binary__tree_a488bf2adcd7de91b9e259f6ef8c7762b}{construct\+\_\+binary\+\_\+tree}} (vector$<$ T $>$ values, int index, T space)
\begin{DoxyCompactList}\small\item\em 层先法构造普通二叉树（支持空节点） \end{DoxyCompactList}\item 
void \mbox{\hyperlink{classmy__binary__tree_a6f45e4cb6774b092b40bee77ee80b757}{mirror}} ()
\begin{DoxyCompactList}\small\item\em 二叉树镜像（交换所有节点的左右子树） \end{DoxyCompactList}\item 
bool \mbox{\hyperlink{classmy__binary__tree_a8fc393aceaa7e46fc5fb6b9377c12ea3}{is\+\_\+empty}} ()
\begin{DoxyCompactList}\small\item\em 判断二叉树是否为空 \end{DoxyCompactList}\item 
T \mbox{\hyperlink{classmy__binary__tree_a05b6069959ff87dc7824ce4e05db024a}{get\+\_\+value}} ()
\begin{DoxyCompactList}\small\item\em 打印当前节点的数据值 \end{DoxyCompactList}\item 
T \mbox{\hyperlink{classmy__binary__tree_ace03005196f04451f9af5c2ab663a990}{get\+\_\+value}} (string position)
\begin{DoxyCompactList}\small\item\em 打印当前节点的数据值 \end{DoxyCompactList}\item 
int \mbox{\hyperlink{classmy__binary__tree_a047c1a5b1fb76a0cb62700eb1c53bb8b}{get\+\_\+height}} ()
\begin{DoxyCompactList}\small\item\em 计算二叉树的高度 \end{DoxyCompactList}\item 
int \mbox{\hyperlink{classmy__binary__tree_ad8ae3e1b3073a79df62de135e337192a}{get\+\_\+h\+\_\+layer\+\_\+nodes}} (int h)
\begin{DoxyCompactList}\small\item\em 计算第h层的节点总数 \end{DoxyCompactList}\item 
int \mbox{\hyperlink{classmy__binary__tree_a76f83530b098d7ad84262d21c885c15d}{get\+\_\+last\+\_\+layer\+\_\+nodes}} ()
\begin{DoxyCompactList}\small\item\em 计算最后一层（叶子节点层）的节点总数 \end{DoxyCompactList}\item 
int \mbox{\hyperlink{classmy__binary__tree_aabf0c965e92e633f4d25f9b88da19a28}{get\+\_\+nodes\+\_\+num}} ()
\begin{DoxyCompactList}\small\item\em 计算二叉树的总节点数 \end{DoxyCompactList}\item 
\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ \texorpdfstring{$\ast$}{*} \mbox{\hyperlink{classmy__binary__tree_a9279b204f13b6f6e79646fe38387607a}{get\+\_\+lrest\+\_\+leave}} (string l\+\_\+or\+\_\+r)
\begin{DoxyCompactList}\small\item\em 获取最左或最右的叶子节点 \end{DoxyCompactList}\item 
bool \mbox{\hyperlink{classmy__binary__tree_adb685df412bb6481f5167165312868ad}{is\+\_\+binary\+\_\+search\+\_\+tree}} ()
\begin{DoxyCompactList}\small\item\em 判断二叉树是否为二叉搜索树（\+BST） \end{DoxyCompactList}\item 
\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ \texorpdfstring{$\ast$}{*} \mbox{\hyperlink{classmy__binary__tree_a490bf7f8ebe87b6040b1294f73979fea}{find}} (int val)
\begin{DoxyCompactList}\small\item\em 查找值为val的节点 \end{DoxyCompactList}\item 
\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ \texorpdfstring{$\ast$}{*} \mbox{\hyperlink{classmy__binary__tree_ad767eada19d83ada460c5eb0c2104056}{find\+\_\+father}} (\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ \texorpdfstring{$\ast$}{*}son)
\begin{DoxyCompactList}\small\item\em 查找指定节点的父节点 \end{DoxyCompactList}\item 
bool \mbox{\hyperlink{classmy__binary__tree_a35c9081b6b3dfe457c8d29697ccfdfb1}{is\+\_\+balence\+\_\+binary\+\_\+tree}} ()
\begin{DoxyCompactList}\small\item\em 判断二叉树是否为平衡二叉树（左右子树高度差不超过1） \end{DoxyCompactList}\item 
void \mbox{\hyperlink{classmy__binary__tree_aa23b0dbc0a4f4f7741111867f6d8b2e9}{append}} (\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ \texorpdfstring{$\ast$}{*}another\+\_\+tree, string l\+\_\+or\+\_\+r)
\begin{DoxyCompactList}\small\item\em 向当前节点追加左/右子树 \end{DoxyCompactList}\item 
void \mbox{\hyperlink{classmy__binary__tree_a19f020b91ef749755745ac08d69be0b6}{copy}} (\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ \texorpdfstring{$\ast$}{*}des, \mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ \texorpdfstring{$\ast$}{*}src)
\begin{DoxyCompactList}\small\item\em 复制二叉树（从src拷贝到des） \end{DoxyCompactList}\item 
void \mbox{\hyperlink{classmy__binary__tree_a9675071237ce43751138c4fa3ef43657}{insert}} (T val, string position)
\begin{DoxyCompactList}\small\item\em 插入节点（未实现） \end{DoxyCompactList}\item 
void \mbox{\hyperlink{classmy__binary__tree_a24a14198a85ebfd603f5284ef9940e41}{delete\+\_\+point}} (\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ \texorpdfstring{$\ast$}{*}point)
\begin{DoxyCompactList}\small\item\em 删除节点（未实现） \end{DoxyCompactList}\item 
void \mbox{\hyperlink{classmy__binary__tree_a5fe4fbbeb0729ef67cc258d2a5350860}{delete\+\_\+pos}} (string position)
\begin{DoxyCompactList}\small\item\em 删除节点（未实现） \end{DoxyCompactList}\item 
\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ \texorpdfstring{$\ast$}{*} \mbox{\hyperlink{classmy__binary__tree_a5842011f1564adb291d8a62f1f7e7625}{revolve}} (string mode)
\begin{DoxyCompactList}\small\item\em 旋转二叉树（未实现） \end{DoxyCompactList}\item 
\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ \texorpdfstring{$\ast$}{*} \mbox{\hyperlink{classmy__binary__tree_abf00c3450fd579d439c231202d2af556}{revolve}} (\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ \texorpdfstring{$\ast$}{*}node, string mode)
\begin{DoxyCompactList}\small\item\em 旋转二叉树（未实现） \end{DoxyCompactList}\item 
void \mbox{\hyperlink{classmy__binary__tree_a3b473ee42358d2ecda1958b1b72fd1dd}{show\+\_\+binary\+\_\+tree}} (string mode)
\begin{DoxyCompactList}\small\item\em 遍历二叉树并打印节点值 \end{DoxyCompactList}\item 
{\footnotesize template$<$typename Function$>$ }\\Function \mbox{\hyperlink{classmy__binary__tree_a4a4f092d8f75d1f8840db3c3b4b6f36e}{traversal\+\_\+binary\+\_\+tree}} (string mode, Function F)
\begin{DoxyCompactList}\small\item\em 遍历二叉树并执行自定义函数（无空节点处理） \end{DoxyCompactList}\item 
{\footnotesize template$<$typename Function1, typename Function2$>$ }\\Function1 \mbox{\hyperlink{classmy__binary__tree_ad3840bd8912df340bc10aa59bc89d1bd}{traversal\+\_\+binary\+\_\+tree}} (string mode, Function1 F1, Function2 F2)
\begin{DoxyCompactList}\small\item\em 遍历二叉树并执行自定义函数（含空节点处理） \end{DoxyCompactList}\item 
void \mbox{\hyperlink{classmy__binary__tree_aff9c3c138c4fc970016a826ec0653eaf}{print\+\_\+full\+\_\+to\+\_\+vector}} (vector$<$ T $>$ \&vv)
\begin{DoxyCompactList}\small\item\em 层序遍历二叉树，将节点值存入向量（不含占位符） \end{DoxyCompactList}\item 
void \mbox{\hyperlink{classmy__binary__tree_aa65e9e0bae93b835e20c32de429928d3}{print\+\_\+to\+\_\+vector}} (vector$<$ T $>$ \&vv)
\begin{DoxyCompactList}\small\item\em 层序遍历二叉树，将节点值存入向量（空节点用占位符） \end{DoxyCompactList}\item 
\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ \& \mbox{\hyperlink{classmy__binary__tree_aedeb2af1e014d361fb7c2f1423e9f58d}{operator=}} (\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ \&other)
\begin{DoxyCompactList}\small\item\em 赋值运算符重载（深拷贝） \end{DoxyCompactList}\item 
T \mbox{\hyperlink{classmy__binary__tree_a52db051eb0ccae70e61baf638acd2f81}{operator\mbox{[}$\,$\mbox{]}}} (int index)
\begin{DoxyCompactList}\small\item\em 索引运算符重载 \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsubsection*{Protected Attributes}
\begin{DoxyCompactItemize}
\item 
\Hypertarget{classmy__binary__tree_ae2d15edcaec6e5543a5e8c64ea0173cb}\label{classmy__binary__tree_ae2d15edcaec6e5543a5e8c64ea0173cb} 
T {\bfseries data}
\begin{DoxyCompactList}\small\item\em 节点存储的数据 \end{DoxyCompactList}\item 
\Hypertarget{classmy__binary__tree_a69a6f187348e8b6219809620e784d3cf}\label{classmy__binary__tree_a69a6f187348e8b6219809620e784d3cf} 
\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ \texorpdfstring{$\ast$}{*} {\bfseries left}
\begin{DoxyCompactList}\small\item\em 左子树指针 \end{DoxyCompactList}\item 
\Hypertarget{classmy__binary__tree_a8910dc810a9a95fe4dc308eeef739b6a}\label{classmy__binary__tree_a8910dc810a9a95fe4dc308eeef739b6a} 
\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ \texorpdfstring{$\ast$}{*} {\bfseries right}
\begin{DoxyCompactList}\small\item\em 右子树指针 \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsubsection*{Friends}
\begin{DoxyCompactItemize}
\item 
bool \mbox{\hyperlink{classmy__binary__tree_a9b5581a82079878a7faac62d07bbcc12}{operator==}} (\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ lhs, \mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ rhs)
\begin{DoxyCompactList}\small\item\em 相等运算符重载（判断两棵树是否完全相同） \end{DoxyCompactList}\item 
bool \mbox{\hyperlink{classmy__binary__tree_a57bcf0e8e11dcb2db4d3c2b72e62d913}{operator!=}} (\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ lhs, \mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ rhs)
\begin{DoxyCompactList}\small\item\em 不等运算符重载 \end{DoxyCompactList}\item 
ostream \& \mbox{\hyperlink{classmy__binary__tree_a9b9d88b02caf22fc6de3a78e3a514816}{operator$<$$<$}} (ostream \&os, \mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ p)
\begin{DoxyCompactList}\small\item\em 输出运算符重载（格式化打印二叉树） \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
\subsubsection*{template$<$typename T$>$\newline
class my\+\_\+binary\+\_\+tree$<$ T $>$}
二叉树类（模板类，支持任意数据类型\+T） 


\begin{DoxyTemplParams}{Template Parameters}
{\em T} & 二叉树节点存储的数据类型 \\
\hline
\end{DoxyTemplParams}
\begin{DoxyNote}{Note}
支持二叉树的构建、遍历、查询、修改等操作，包含常见的二叉树算法实现 
\end{DoxyNote}


\label{doc-constructors}
\Hypertarget{classmy__binary__tree_doc-constructors}
\doxysubsection{Constructor \& Destructor Documentation}
\Hypertarget{classmy__binary__tree_ae19ca02504d47a17836f0b0c533f8982}\index{my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}!my\_binary\_tree@{my\_binary\_tree}}
\index{my\_binary\_tree@{my\_binary\_tree}!my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}}
\doxysubsubsection{\texorpdfstring{my\_binary\_tree()}{my\_binary\_tree()}\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily \label{classmy__binary__tree_ae19ca02504d47a17836f0b0c533f8982} 
template$<$typename T$>$ \\
\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$\mbox{\hyperlink{classmy__binary__tree}{\+::my\+\_\+binary\+\_\+tree}} (\begin{DoxyParamCaption}\item[{T}]{val}{}\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



构造函数（创建单个节点） 


\begin{DoxyParams}{Parameters}
{\em val} & 节点存储的数据值 \\
\hline
\end{DoxyParams}
\begin{DoxyNote}{Note}
初始时左、右子树均为\+NULL；示例：my\+\_\+binary\+\_\+tree$<$int$>$ node(5); 
\end{DoxyNote}
\Hypertarget{classmy__binary__tree_a6faf690077dab82f4d1f72920c3834fd}\index{my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}!my\_binary\_tree@{my\_binary\_tree}}
\index{my\_binary\_tree@{my\_binary\_tree}!my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}}
\doxysubsubsection{\texorpdfstring{my\_binary\_tree()}{my\_binary\_tree()}\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily \label{classmy__binary__tree_a6faf690077dab82f4d1f72920c3834fd} 
template$<$typename T$>$ \\
\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$\mbox{\hyperlink{classmy__binary__tree}{\+::my\+\_\+binary\+\_\+tree}} (\begin{DoxyParamCaption}\item[{const \mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ \&}]{other}{}\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



拷贝构造函数（深拷贝） 


\begin{DoxyParams}{Parameters}
{\em other} & 待拷贝的二叉树对象 \\
\hline
\end{DoxyParams}
\begin{DoxyNote}{Note}
递归拷贝所有子节点，避免浅拷贝导致的内存问题；示例：my\+\_\+binary\+\_\+tree$<$int$>$ a(b); 
\end{DoxyNote}
\Hypertarget{classmy__binary__tree_aabd378c4f70ed8c8e76691769d111c59}\index{my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}!````~my\_binary\_tree@{\texorpdfstring{$\sim$}{\string~}my\_binary\_tree}}
\index{````~my\_binary\_tree@{\texorpdfstring{$\sim$}{\string~}my\_binary\_tree}!my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}}
\doxysubsubsection{\texorpdfstring{\texorpdfstring{$\sim$}{\string~}my\_binary\_tree()}{\string~my\_binary\_tree()}}
{\footnotesize\ttfamily \label{classmy__binary__tree_aabd378c4f70ed8c8e76691769d111c59} 
template$<$typename T$>$ \\
\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$\+::\texorpdfstring{$\sim$}{\string~}\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}} (\begin{DoxyParamCaption}{}{}\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



析构函数（递归释放内存） 

\begin{DoxyNote}{Note}
先释放左子树，再释放右子树，避免内存泄漏 
\end{DoxyNote}


\label{doc-func-members}
\Hypertarget{classmy__binary__tree_doc-func-members}
\doxysubsection{Member Function Documentation}
\Hypertarget{classmy__binary__tree_aa23b0dbc0a4f4f7741111867f6d8b2e9}\index{my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}!append@{append}}
\index{append@{append}!my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}}
\doxysubsubsection{\texorpdfstring{append()}{append()}}
{\footnotesize\ttfamily \label{classmy__binary__tree_aa23b0dbc0a4f4f7741111867f6d8b2e9} 
template$<$typename T$>$ \\
void \mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$\+::append (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ \texorpdfstring{$\ast$}{*}}]{another\+\_\+tree}{, }\item[{string}]{l\+\_\+or\+\_\+r}{}\end{DoxyParamCaption})}



向当前节点追加左/右子树 


\begin{DoxyParams}{Parameters}
{\em another\+\_\+tree} & 待追加的子树指针 \\
\hline
{\em l\+\_\+or\+\_\+r} & 追加位置："{}left"{}表示左子树，"{}right"{}表示右子树 \\
\hline
\end{DoxyParams}
\begin{DoxyNote}{Note}
若目标位置已有子树（非\+NULL），会触发断言失败（assert） 
\end{DoxyNote}
\Hypertarget{classmy__binary__tree_a488bf2adcd7de91b9e259f6ef8c7762b}\index{my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}!construct\_binary\_tree@{construct\_binary\_tree}}
\index{construct\_binary\_tree@{construct\_binary\_tree}!my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}}
\doxysubsubsection{\texorpdfstring{construct\_binary\_tree()}{construct\_binary\_tree()}}
{\footnotesize\ttfamily \label{classmy__binary__tree_a488bf2adcd7de91b9e259f6ef8c7762b} 
template$<$typename T$>$ \\
\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ \texorpdfstring{$\ast$}{*} \mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$\+::construct\+\_\+binary\+\_\+tree (\begin{DoxyParamCaption}\item[{vector$<$ T $>$}]{values}{, }\item[{int}]{index}{, }\item[{T}]{space}{}\end{DoxyParamCaption})}



层先法构造普通二叉树（支持空节点） 


\begin{DoxyParams}{Parameters}
{\em values} & 存储节点数据的向量（按层序排列，空节点用space标记） \\
\hline
{\em index} & 当前构造的节点在向量中的索引（初始为0） \\
\hline
{\em space} & 空节点的标记值（通常使用全局常量space） \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
构造完成的二叉树根节点指针（空节点返回\+NULL） 
\end{DoxyReturn}
\begin{DoxyNote}{Note}
向量中值为space的位置表示对应节点为空 
\end{DoxyNote}
\Hypertarget{classmy__binary__tree_a19f020b91ef749755745ac08d69be0b6}\index{my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}!copy@{copy}}
\index{copy@{copy}!my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}}
\doxysubsubsection{\texorpdfstring{copy()}{copy()}}
{\footnotesize\ttfamily \label{classmy__binary__tree_a19f020b91ef749755745ac08d69be0b6} 
template$<$typename T$>$ \\
void \mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$\+::copy (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ \texorpdfstring{$\ast$}{*}}]{des}{, }\item[{\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ \texorpdfstring{$\ast$}{*}}]{src}{}\end{DoxyParamCaption})}



复制二叉树（从src拷贝到des） 


\begin{DoxyParams}{Parameters}
{\em des} & 目标二叉树指针（需提前创建） \\
\hline
{\em src} & 源二叉树指针 \\
\hline
\end{DoxyParams}
\begin{DoxyNote}{Note}
拷贝data、left、right成员（浅拷贝，仅复制指针，不递归拷贝子树） 
\end{DoxyNote}
\Hypertarget{classmy__binary__tree_a24a14198a85ebfd603f5284ef9940e41}\index{my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}!delete\_point@{delete\_point}}
\index{delete\_point@{delete\_point}!my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}}
\doxysubsubsection{\texorpdfstring{delete\_point()}{delete\_point()}}
{\footnotesize\ttfamily \label{classmy__binary__tree_a24a14198a85ebfd603f5284ef9940e41} 
template$<$typename T$>$ \\
void \mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$\+::delete\+\_\+point (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ \texorpdfstring{$\ast$}{*}}]{point}{}\end{DoxyParamCaption})}



删除节点（未实现） 


\begin{DoxyParams}{Parameters}
{\em point} & 待删除的指针 \\
\hline
\end{DoxyParams}
\begin{DoxyNote}{Note}
函数体为空，需补充实现逻辑 
\end{DoxyNote}
\Hypertarget{classmy__binary__tree_a5fe4fbbeb0729ef67cc258d2a5350860}\index{my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}!delete\_pos@{delete\_pos}}
\index{delete\_pos@{delete\_pos}!my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}}
\doxysubsubsection{\texorpdfstring{delete\_pos()}{delete\_pos()}}
{\footnotesize\ttfamily \label{classmy__binary__tree_a5fe4fbbeb0729ef67cc258d2a5350860} 
template$<$typename T$>$ \\
void \mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$\+::delete\+\_\+pos (\begin{DoxyParamCaption}\item[{string}]{position}{}\end{DoxyParamCaption})}



删除节点（未实现） 


\begin{DoxyParams}{Parameters}
{\em position} & 删除位置标识（预留参数） \\
\hline
\end{DoxyParams}
\begin{DoxyNote}{Note}
函数体为空，需补充实现逻辑 
\end{DoxyNote}
\Hypertarget{classmy__binary__tree_a490bf7f8ebe87b6040b1294f73979fea}\index{my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}!find@{find}}
\index{find@{find}!my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}}
\doxysubsubsection{\texorpdfstring{find()}{find()}}
{\footnotesize\ttfamily \label{classmy__binary__tree_a490bf7f8ebe87b6040b1294f73979fea} 
template$<$typename T$>$ \\
\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ \texorpdfstring{$\ast$}{*} \mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$\+::find (\begin{DoxyParamCaption}\item[{int}]{val}{}\end{DoxyParamCaption})}



查找值为val的节点 


\begin{DoxyParams}{Parameters}
{\em val} & 待查找的值 \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
找到的节点指针（未找到或树为空返回\+NULL） 
\end{DoxyReturn}
\begin{DoxyNote}{Note}
采用先序遍历查找（先查当前节点，再查左子树，最后查右子树） 
\end{DoxyNote}
\Hypertarget{classmy__binary__tree_ad767eada19d83ada460c5eb0c2104056}\index{my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}!find\_father@{find\_father}}
\index{find\_father@{find\_father}!my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}}
\doxysubsubsection{\texorpdfstring{find\_father()}{find\_father()}}
{\footnotesize\ttfamily \label{classmy__binary__tree_ad767eada19d83ada460c5eb0c2104056} 
template$<$typename T$>$ \\
\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ \texorpdfstring{$\ast$}{*} \mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$\+::find\+\_\+father (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ \texorpdfstring{$\ast$}{*}}]{son}{}\end{DoxyParamCaption})}



查找指定节点的父节点 


\begin{DoxyParams}{Parameters}
{\em son} & 待查找父节点的子节点指针 \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
父节点指针（son为根节点或未找到时返回\+NULL） 
\end{DoxyReturn}
\begin{DoxyNote}{Note}
递归遍历树，若当前节点的左/右子树为son，则当前节点为父节点 
\end{DoxyNote}
\Hypertarget{classmy__binary__tree_ad8ae3e1b3073a79df62de135e337192a}\index{my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}!get\_h\_layer\_nodes@{get\_h\_layer\_nodes}}
\index{get\_h\_layer\_nodes@{get\_h\_layer\_nodes}!my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}}
\doxysubsubsection{\texorpdfstring{get\_h\_layer\_nodes()}{get\_h\_layer\_nodes()}}
{\footnotesize\ttfamily \label{classmy__binary__tree_ad8ae3e1b3073a79df62de135e337192a} 
template$<$typename T$>$ \\
int \mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$\+::get\+\_\+h\+\_\+layer\+\_\+nodes (\begin{DoxyParamCaption}\item[{int}]{h}{}\end{DoxyParamCaption})}



计算第h层的节点总数 


\begin{DoxyParams}{Parameters}
{\em h} & 目标层数（h \texorpdfstring{$>$}{>}= 1且h \texorpdfstring{$<$}{<}= 树高，否则触发断言失败） \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
第h层的节点数量 
\end{DoxyReturn}
\begin{DoxyNote}{Note}
采用层序遍历（队列实现），逐层计数节点数量 
\end{DoxyNote}
\Hypertarget{classmy__binary__tree_a047c1a5b1fb76a0cb62700eb1c53bb8b}\index{my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}!get\_height@{get\_height}}
\index{get\_height@{get\_height}!my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}}
\doxysubsubsection{\texorpdfstring{get\_height()}{get\_height()}}
{\footnotesize\ttfamily \label{classmy__binary__tree_a047c1a5b1fb76a0cb62700eb1c53bb8b} 
template$<$typename T$>$ \\
int \mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$\+::get\+\_\+height (\begin{DoxyParamCaption}{}{}\end{DoxyParamCaption})}



计算二叉树的高度 

\begin{DoxyReturn}{Returns}
树的高度（根节点为第1层，空树返回0） 
\end{DoxyReturn}
\begin{DoxyNote}{Note}
递归计算：树高 = 1 + max(左子树高度, 右子树高度) 
\end{DoxyNote}
\Hypertarget{classmy__binary__tree_a76f83530b098d7ad84262d21c885c15d}\index{my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}!get\_last\_layer\_nodes@{get\_last\_layer\_nodes}}
\index{get\_last\_layer\_nodes@{get\_last\_layer\_nodes}!my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}}
\doxysubsubsection{\texorpdfstring{get\_last\_layer\_nodes()}{get\_last\_layer\_nodes()}}
{\footnotesize\ttfamily \label{classmy__binary__tree_a76f83530b098d7ad84262d21c885c15d} 
template$<$typename T$>$ \\
int \mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$\+::get\+\_\+last\+\_\+layer\+\_\+nodes (\begin{DoxyParamCaption}{}{}\end{DoxyParamCaption})}



计算最后一层（叶子节点层）的节点总数 

\begin{DoxyReturn}{Returns}
最后一层的节点数量 
\end{DoxyReturn}
\begin{DoxyNote}{Note}
本质是调用get\+\_\+h\+\_\+layer\+\_\+nodes(get\+\_\+height()) 
\end{DoxyNote}
\Hypertarget{classmy__binary__tree_a9279b204f13b6f6e79646fe38387607a}\index{my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}!get\_lrest\_leave@{get\_lrest\_leave}}
\index{get\_lrest\_leave@{get\_lrest\_leave}!my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}}
\doxysubsubsection{\texorpdfstring{get\_lrest\_leave()}{get\_lrest\_leave()}}
{\footnotesize\ttfamily \label{classmy__binary__tree_a9279b204f13b6f6e79646fe38387607a} 
template$<$typename T$>$ \\
\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ \texorpdfstring{$\ast$}{*} \mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$\+::get\+\_\+lrest\+\_\+leave (\begin{DoxyParamCaption}\item[{string}]{l\+\_\+or\+\_\+r}{}\end{DoxyParamCaption})}



获取最左或最右的叶子节点 


\begin{DoxyParams}{Parameters}
{\em l\+\_\+or\+\_\+r} & 方向标识："{}left"{}表示最左叶子，"{}right"{}表示最右叶子 \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
最左/右叶子节点的指针（若树为空，返回this） 
\end{DoxyReturn}
\begin{DoxyNote}{Note}
最左叶子：从根节点一直向左子树遍历，直到左子树为\+NULL；最右叶子类似 
\end{DoxyNote}
\Hypertarget{classmy__binary__tree_aabf0c965e92e633f4d25f9b88da19a28}\index{my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}!get\_nodes\_num@{get\_nodes\_num}}
\index{get\_nodes\_num@{get\_nodes\_num}!my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}}
\doxysubsubsection{\texorpdfstring{get\_nodes\_num()}{get\_nodes\_num()}}
{\footnotesize\ttfamily \label{classmy__binary__tree_aabf0c965e92e633f4d25f9b88da19a28} 
template$<$typename T$>$ \\
int \mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$\+::get\+\_\+nodes\+\_\+num (\begin{DoxyParamCaption}{}{}\end{DoxyParamCaption})}



计算二叉树的总节点数 

\begin{DoxyReturn}{Returns}
所有层的节点数量之和 
\end{DoxyReturn}
\begin{DoxyNote}{Note}
遍历所有层，累加每层节点数 
\end{DoxyNote}
\Hypertarget{classmy__binary__tree_a05b6069959ff87dc7824ce4e05db024a}\index{my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}!get\_value@{get\_value}}
\index{get\_value@{get\_value}!my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}}
\doxysubsubsection{\texorpdfstring{get\_value()}{get\_value()}\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily \label{classmy__binary__tree_a05b6069959ff87dc7824ce4e05db024a} 
template$<$typename T$>$ \\
T \mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$\+::get\+\_\+value (\begin{DoxyParamCaption}{}{}\end{DoxyParamCaption})}



打印当前节点的数据值 

\begin{DoxyNote}{Note}
直接输出data成员到标准输出流 
\end{DoxyNote}
\Hypertarget{classmy__binary__tree_ace03005196f04451f9af5c2ab663a990}\index{my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}!get\_value@{get\_value}}
\index{get\_value@{get\_value}!my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}}
\doxysubsubsection{\texorpdfstring{get\_value()}{get\_value()}\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily \label{classmy__binary__tree_ace03005196f04451f9af5c2ab663a990} 
template$<$typename T$>$ \\
T \mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$\+::get\+\_\+value (\begin{DoxyParamCaption}\item[{string}]{position}{}\end{DoxyParamCaption})}



打印当前节点的数据值 


\begin{DoxyParams}{Parameters}
{\em position} & 二进制表示位置 \\
\hline
\end{DoxyParams}
\begin{DoxyNote}{Note}
直接输出data成员到标准输出流 
\end{DoxyNote}
\Hypertarget{classmy__binary__tree_a9675071237ce43751138c4fa3ef43657}\index{my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}!insert@{insert}}
\index{insert@{insert}!my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}}
\doxysubsubsection{\texorpdfstring{insert()}{insert()}}
{\footnotesize\ttfamily \label{classmy__binary__tree_a9675071237ce43751138c4fa3ef43657} 
template$<$typename T$>$ \\
void \mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$\+::insert (\begin{DoxyParamCaption}\item[{T}]{val}{, }\item[{string}]{position}{}\end{DoxyParamCaption})}



插入节点（未实现） 


\begin{DoxyParams}{Parameters}
{\em val} & 待插入的节点值 \\
\hline
{\em position} & 插入位置标识（预留参数） \\
\hline
\end{DoxyParams}
\begin{DoxyNote}{Note}
函数体为空，需补充实现逻辑 
\end{DoxyNote}
\Hypertarget{classmy__binary__tree_a35c9081b6b3dfe457c8d29697ccfdfb1}\index{my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}!is\_balence\_binary\_tree@{is\_balence\_binary\_tree}}
\index{is\_balence\_binary\_tree@{is\_balence\_binary\_tree}!my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}}
\doxysubsubsection{\texorpdfstring{is\_balence\_binary\_tree()}{is\_balence\_binary\_tree()}}
{\footnotesize\ttfamily \label{classmy__binary__tree_a35c9081b6b3dfe457c8d29697ccfdfb1} 
template$<$typename T$>$ \\
bool \mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$\+::is\+\_\+balence\+\_\+binary\+\_\+tree (\begin{DoxyParamCaption}{}{}\end{DoxyParamCaption})}



判断二叉树是否为平衡二叉树（左右子树高度差不超过1） 

\begin{DoxyReturn}{Returns}
若是平衡树返回true，否则返回false 
\end{DoxyReturn}
\begin{DoxyNote}{Note}
平衡树定义：任意节点的左右子树高度差 \texorpdfstring{$<$}{<}= 1；递归验证所有节点 
\end{DoxyNote}
\Hypertarget{classmy__binary__tree_adb685df412bb6481f5167165312868ad}\index{my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}!is\_binary\_search\_tree@{is\_binary\_search\_tree}}
\index{is\_binary\_search\_tree@{is\_binary\_search\_tree}!my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}}
\doxysubsubsection{\texorpdfstring{is\_binary\_search\_tree()}{is\_binary\_search\_tree()}}
{\footnotesize\ttfamily \label{classmy__binary__tree_adb685df412bb6481f5167165312868ad} 
template$<$typename T$>$ \\
bool \mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$\+::is\+\_\+binary\+\_\+search\+\_\+tree (\begin{DoxyParamCaption}{}{}\end{DoxyParamCaption})}



判断二叉树是否为二叉搜索树（\+BST） 

\begin{DoxyReturn}{Returns}
若是\+BST返回true，否则返回false 
\end{DoxyReturn}
\begin{DoxyNote}{Note}
BST定义：左子树所有节点值 \texorpdfstring{$<$}{<}= 当前节点值 \texorpdfstring{$<$}{<}= 右子树所有节点值；递归验证左右子树 
\end{DoxyNote}
\Hypertarget{classmy__binary__tree_a8fc393aceaa7e46fc5fb6b9377c12ea3}\index{my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}!is\_empty@{is\_empty}}
\index{is\_empty@{is\_empty}!my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}}
\doxysubsubsection{\texorpdfstring{is\_empty()}{is\_empty()}}
{\footnotesize\ttfamily \label{classmy__binary__tree_a8fc393aceaa7e46fc5fb6b9377c12ea3} 
template$<$typename T$>$ \\
bool \mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$\+::is\+\_\+empty (\begin{DoxyParamCaption}{}{}\end{DoxyParamCaption})}



判断二叉树是否为空 

\begin{DoxyReturn}{Returns}
若树为空（this == NULL），返回true；否则返回false 
\end{DoxyReturn}
\Hypertarget{classmy__binary__tree_a6f45e4cb6774b092b40bee77ee80b757}\index{my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}!mirror@{mirror}}
\index{mirror@{mirror}!my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}}
\doxysubsubsection{\texorpdfstring{mirror()}{mirror()}}
{\footnotesize\ttfamily \label{classmy__binary__tree_a6f45e4cb6774b092b40bee77ee80b757} 
template$<$typename T$>$ \\
void \mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$\+::mirror (\begin{DoxyParamCaption}{}{}\end{DoxyParamCaption})}



二叉树镜像（交换所有节点的左右子树） 

\begin{DoxyNote}{Note}
递归交换当前节点的左右子树，再分别镜像左、右子树 
\end{DoxyNote}
\Hypertarget{classmy__binary__tree_aedeb2af1e014d361fb7c2f1423e9f58d}\index{my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}!operator=@{operator=}}
\index{operator=@{operator=}!my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}}
\doxysubsubsection{\texorpdfstring{operator=()}{operator=()}}
{\footnotesize\ttfamily \label{classmy__binary__tree_aedeb2af1e014d361fb7c2f1423e9f58d} 
template$<$typename T$>$ \\
\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ \& \mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$\+::operator= (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ \&}]{other}{}\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



赋值运算符重载（深拷贝） 


\begin{DoxyParams}{Parameters}
{\em other} & 待赋值的二叉树对象 \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
当前对象的引用（\texorpdfstring{$\ast$}{*}this） 
\end{DoxyReturn}
\begin{DoxyNote}{Note}
先释放当前对象的子树内存，再递归拷贝other的子树，避免内存泄漏 
\end{DoxyNote}
\Hypertarget{classmy__binary__tree_a52db051eb0ccae70e61baf638acd2f81}\index{my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}!operator\mbox{[}\mbox{]}@{operator[]}}
\index{operator\mbox{[}\mbox{]}@{operator[]}!my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}}
\doxysubsubsection{\texorpdfstring{operator[]()}{operator[]()}}
{\footnotesize\ttfamily \label{classmy__binary__tree_a52db051eb0ccae70e61baf638acd2f81} 
template$<$typename T$>$ \\
T \mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$\+::operator\mbox{[}$\,$\mbox{]} (\begin{DoxyParamCaption}\item[{int}]{index}{}\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



索引运算符重载 


\begin{DoxyParams}{Parameters}
{\em index} & 待打印的索引号 \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
index位置的值（不可更改） 
\end{DoxyReturn}
\begin{DoxyNote}{Note}
按层打印节点，空节点assert error 
\end{DoxyNote}
\Hypertarget{classmy__binary__tree_aff9c3c138c4fc970016a826ec0653eaf}\index{my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}!print\_full\_to\_vector@{print\_full\_to\_vector}}
\index{print\_full\_to\_vector@{print\_full\_to\_vector}!my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}}
\doxysubsubsection{\texorpdfstring{print\_full\_to\_vector()}{print\_full\_to\_vector()}}
{\footnotesize\ttfamily \label{classmy__binary__tree_aff9c3c138c4fc970016a826ec0653eaf} 
template$<$typename T$>$ \\
void \mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$\+::print\+\_\+full\+\_\+to\+\_\+vector (\begin{DoxyParamCaption}\item[{vector$<$ T $>$ \&}]{vv}{}\end{DoxyParamCaption})}



层序遍历二叉树，将节点值存入向量（不含占位符） 


\begin{DoxyParams}{Parameters}
{\em vv} & 存储结果的向量引用 \\
\hline
\end{DoxyParams}
\begin{DoxyNote}{Note}
调用traversal\+\_\+binary\+\_\+tree，配合print\+\_\+fulltov函数实现 
\end{DoxyNote}
\Hypertarget{classmy__binary__tree_aa65e9e0bae93b835e20c32de429928d3}\index{my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}!print\_to\_vector@{print\_to\_vector}}
\index{print\_to\_vector@{print\_to\_vector}!my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}}
\doxysubsubsection{\texorpdfstring{print\_to\_vector()}{print\_to\_vector()}}
{\footnotesize\ttfamily \label{classmy__binary__tree_aa65e9e0bae93b835e20c32de429928d3} 
template$<$typename T$>$ \\
void \mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$\+::print\+\_\+to\+\_\+vector (\begin{DoxyParamCaption}\item[{vector$<$ T $>$ \&}]{vv}{}\end{DoxyParamCaption})}



层序遍历二叉树，将节点值存入向量（空节点用占位符） 


\begin{DoxyParams}{Parameters}
{\em vv} & 存储结果的向量引用（需提前分配空间，空节点用space标记） \\
\hline
\end{DoxyParams}
\begin{DoxyNote}{Note}
调用traversal\+\_\+binary\+\_\+tree，配合print\+\_\+tov和empty\+\_\+function实现 
\end{DoxyNote}
\Hypertarget{classmy__binary__tree_abf00c3450fd579d439c231202d2af556}\index{my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}!revolve@{revolve}}
\index{revolve@{revolve}!my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}}
\doxysubsubsection{\texorpdfstring{revolve()}{revolve()}\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily \label{classmy__binary__tree_abf00c3450fd579d439c231202d2af556} 
template$<$typename T$>$ \\
\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ \texorpdfstring{$\ast$}{*} \mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$\+::revolve (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ \texorpdfstring{$\ast$}{*}}]{node}{, }\item[{string}]{mode}{}\end{DoxyParamCaption})}



旋转二叉树（未实现） 


\begin{DoxyParams}{Parameters}
{\em node} & 不平衡的节点 \\
\hline
{\em mode} & 旋转模式 \\
\hline
\end{DoxyParams}
\begin{DoxyNote}{Note}
函数体为空，需补充实现逻辑 
\end{DoxyNote}
\Hypertarget{classmy__binary__tree_a5842011f1564adb291d8a62f1f7e7625}\index{my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}!revolve@{revolve}}
\index{revolve@{revolve}!my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}}
\doxysubsubsection{\texorpdfstring{revolve()}{revolve()}\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily \label{classmy__binary__tree_a5842011f1564adb291d8a62f1f7e7625} 
template$<$typename T$>$ \\
\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$ \texorpdfstring{$\ast$}{*} \mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$\+::revolve (\begin{DoxyParamCaption}\item[{string}]{mode}{}\end{DoxyParamCaption})}



旋转二叉树（未实现） 


\begin{DoxyParams}{Parameters}
{\em mode} & 旋转模式 \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
旋转后的树 
\end{DoxyReturn}
\begin{DoxyNote}{Note}
函数体为空，需补充实现逻辑 
\end{DoxyNote}
\Hypertarget{classmy__binary__tree_a3b473ee42358d2ecda1958b1b72fd1dd}\index{my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}!show\_binary\_tree@{show\_binary\_tree}}
\index{show\_binary\_tree@{show\_binary\_tree}!my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}}
\doxysubsubsection{\texorpdfstring{show\_binary\_tree()}{show\_binary\_tree()}}
{\footnotesize\ttfamily \label{classmy__binary__tree_a3b473ee42358d2ecda1958b1b72fd1dd} 
template$<$typename T$>$ \\
void \mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$\+::show\+\_\+binary\+\_\+tree (\begin{DoxyParamCaption}\item[{string}]{mode}{}\end{DoxyParamCaption})}



遍历二叉树并打印节点值 


\begin{DoxyParams}{Parameters}
{\em mode} & 遍历方式："{}first\+\_\+root"{}（先序）、"{}mid\+\_\+root"{}（中序）、"{}last\+\_\+root"{}（后序）、"{}layer\+\_\+first"{}（层序） \\
\hline
\end{DoxyParams}
\begin{DoxyNote}{Note}
不同遍历方式的节点访问顺序不同，结果直接输出到标准输出流 
\end{DoxyNote}
\Hypertarget{classmy__binary__tree_a4a4f092d8f75d1f8840db3c3b4b6f36e}\index{my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}!traversal\_binary\_tree@{traversal\_binary\_tree}}
\index{traversal\_binary\_tree@{traversal\_binary\_tree}!my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}}
\doxysubsubsection{\texorpdfstring{traversal\_binary\_tree()}{traversal\_binary\_tree()}\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily \label{classmy__binary__tree_a4a4f092d8f75d1f8840db3c3b4b6f36e} 
template$<$typename T$>$ \\
template$<$typename Function$>$ \\
Function \mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$\+::traversal\+\_\+binary\+\_\+tree (\begin{DoxyParamCaption}\item[{string}]{mode}{, }\item[{Function}]{F}{}\end{DoxyParamCaption})}



遍历二叉树并执行自定义函数（无空节点处理） 


\begin{DoxyTemplParams}{Template Parameters}
{\em Function} & 函数类型（需接收\+T类型参数，无返回值） \\
\hline
\end{DoxyTemplParams}

\begin{DoxyParams}{Parameters}
{\em mode} & 遍历方式（同show\+\_\+binary\+\_\+tree） \\
\hline
{\em F} & 待执行的函数（如print、self\+\_\+increase等） \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
传入的函数\+F（便于链式调用） 
\end{DoxyReturn}
\begin{DoxyNote}{Note}
遍历到的每个节点会作为参数传入\+F；空节点不做处理 
\end{DoxyNote}
\Hypertarget{classmy__binary__tree_ad3840bd8912df340bc10aa59bc89d1bd}\index{my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}!traversal\_binary\_tree@{traversal\_binary\_tree}}
\index{traversal\_binary\_tree@{traversal\_binary\_tree}!my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}}
\doxysubsubsection{\texorpdfstring{traversal\_binary\_tree()}{traversal\_binary\_tree()}\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily \label{classmy__binary__tree_ad3840bd8912df340bc10aa59bc89d1bd} 
template$<$typename T$>$ \\
template$<$typename Function1, typename Function2$>$ \\
Function1 \mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$\+::traversal\+\_\+binary\+\_\+tree (\begin{DoxyParamCaption}\item[{string}]{mode}{, }\item[{Function1}]{F1}{, }\item[{Function2}]{F2}{}\end{DoxyParamCaption})}



遍历二叉树并执行自定义函数（含空节点处理） 


\begin{DoxyTemplParams}{Template Parameters}
{\em Function1} & 非空节点处理函数类型（接收\+T类型参数） \\
\hline
{\em Function2} & 空节点处理函数类型（无参数） \\
\hline
\end{DoxyTemplParams}

\begin{DoxyParams}{Parameters}
{\em mode} & 遍历方式（同show\+\_\+binary\+\_\+tree） \\
\hline
{\em F1} & 非空节点执行的函数 \\
\hline
{\em F2} & 空节点执行的函数 \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
传入的函数\+F1（便于链式调用） 
\end{DoxyReturn}
\begin{DoxyNote}{Note}
层序遍历时会显式处理空节点（调用\+F2），其他遍历方式仅在递归到空节点时调用\+F2 
\end{DoxyNote}


\label{doc-related-members}
\Hypertarget{classmy__binary__tree_doc-related-members}
\doxysubsection{Friends And Related Symbol Documentation}
\Hypertarget{classmy__binary__tree_a57bcf0e8e11dcb2db4d3c2b72e62d913}\index{my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}!operator"!=@{operator"!=}}
\index{operator"!=@{operator"!=}!my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}}
\doxysubsubsection{\texorpdfstring{operator"!=}{operator!=}}
{\footnotesize\ttfamily \label{classmy__binary__tree_a57bcf0e8e11dcb2db4d3c2b72e62d913} 
template$<$typename T$>$ \\
bool operator!= (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$}]{lhs}{, }\item[{\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$}]{rhs}{}\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [friend]}}



不等运算符重载 


\begin{DoxyParams}{Parameters}
{\em lhs} & 左操作数（二叉树对象） \\
\hline
{\em rhs} & 右操作数（二叉树对象） \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
若两棵树不相等，返回true；否则返回false 
\end{DoxyReturn}
\begin{DoxyNote}{Note}
等价于!(lhs == rhs) 
\end{DoxyNote}
\Hypertarget{classmy__binary__tree_a9b9d88b02caf22fc6de3a78e3a514816}\index{my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}!operator$<$$<$@{operator$<$$<$}}
\index{operator$<$$<$@{operator$<$$<$}!my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}}
\doxysubsubsection{\texorpdfstring{operator$<$$<$}{operator<<}}
{\footnotesize\ttfamily \label{classmy__binary__tree_a9b9d88b02caf22fc6de3a78e3a514816} 
template$<$typename T$>$ \\
ostream \& operator$<$$<$ (\begin{DoxyParamCaption}\item[{ostream \&}]{os}{, }\item[{\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$}]{p}{}\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [friend]}}



输出运算符重载（格式化打印二叉树） 


\begin{DoxyParams}{Parameters}
{\em os} & 输出流对象 \\
\hline
{\em p} & 待打印的二叉树对象 \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
输出流对象（便于链式输出） 
\end{DoxyReturn}
\begin{DoxyNote}{Note}
按层打印节点，空节点用\textquotesingle{}\texorpdfstring{$\ast$}{*}\textquotesingle{}表示，节点间用空格分隔，模拟树形结构 
\end{DoxyNote}
\Hypertarget{classmy__binary__tree_a9b5581a82079878a7faac62d07bbcc12}\index{my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}!operator==@{operator==}}
\index{operator==@{operator==}!my\_binary\_tree$<$ T $>$@{my\_binary\_tree$<$ T $>$}}
\doxysubsubsection{\texorpdfstring{operator==}{operator==}}
{\footnotesize\ttfamily \label{classmy__binary__tree_a9b5581a82079878a7faac62d07bbcc12} 
template$<$typename T$>$ \\
bool operator== (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$}]{lhs}{, }\item[{\mbox{\hyperlink{classmy__binary__tree}{my\+\_\+binary\+\_\+tree}}$<$ T $>$}]{rhs}{}\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [friend]}}



相等运算符重载（判断两棵树是否完全相同） 


\begin{DoxyParams}{Parameters}
{\em lhs} & 左操作数（二叉树对象） \\
\hline
{\em rhs} & 右操作数（二叉树对象） \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
若结构和节点值完全相同，返回true；否则返回false 
\end{DoxyReturn}
\begin{DoxyNote}{Note}
递归判断：当前节点值相等 + 左子树相等 + 右子树相等 
\end{DoxyNote}


The documentation for this class was generated from the following file\+:\begin{DoxyCompactItemize}
\item 
my\+\_\+binary\+\_\+tree.\+h\end{DoxyCompactItemize}
